<!DOCTYPE html>
<html lang="zh-CN">





<head>
  <meta charset="UTF-8">
  <link rel="apple-touch-icon" sizes="76x76" href="https://s2.ax1x.com/2020/01/23/1EwDcq.png">
  <link rel="icon" type="image/png" href="https://s2.ax1x.com/2020/01/23/1EwDcq.png">
  <meta name="viewport"
        content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  
  <meta name="description" content="">
  <meta name="author" content="Fansure Grin">
  <meta name="keywords" content="share,hexo,blog,博客,分享">
  <title>Hexo博客部署到Gitee(码云)平台，开启Pages 服务 | Fansure的小栈</title>

  <link rel="stylesheet" href="/lib/font-awesome/css/all.min.css"  >
<link rel="stylesheet" href="/lib/bootstrap/css/bootstrap.min.css"  >
<link rel="stylesheet" href="/lib/mdbootstrap/css/mdb.min.css"  >
<link rel="stylesheet" href="/lib/github-markdown/github-markdown.min.css"  >

<link rel="stylesheet" href="//at.alicdn.com/t/font_1067060_qzomjdt8bmp.css">



  <link rel="stylesheet" href="/lib/prettify/tomorrow-night-eighties.min.css"  >

<link rel="stylesheet" href="/css/main.css"  >


  <link rel="stylesheet" href="/lib/fancybox/jquery.fancybox.min.css"  >


<meta name="generator" content="Hexo 4.2.0"></head>


<body>
  <header style="height: 70vh;">
    <nav id="navbar" class="navbar fixed-top  navbar-expand-lg navbar-dark scrolling-navbar">
  <div class="container">
    <a class="navbar-brand"
       href="/">&nbsp;<strong>Fansure的小栈</strong>&nbsp;</a>

    <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <div class="animated-icon"><span></span><span></span><span></span></div>
    </button>

    <!-- Collapsible content -->
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav ml-auto text-center">
        
          
          
          
          
          <li class="nav-item">
            <a class="nav-link" href="/">首页</a>
          </li>
        
          
          
          
          
          <li class="nav-item">
            <a class="nav-link" href="/archives/">归档</a>
          </li>
        
          
          
          
          
          <li class="nav-item">
            <a class="nav-link" href="/categories/">分类</a>
          </li>
        
          
          
          
          
          <li class="nav-item">
            <a class="nav-link" href="/tags/">标签</a>
          </li>
        
          
          
          
          
          <li class="nav-item">
            <a class="nav-link" href="/about/">关于</a>
          </li>
        
        
          <li class="nav-item" id="search-btn">
            <a class="nav-link" data-toggle="modal" data-target="#modalSearch">&nbsp;&nbsp;<i
                class="iconfont icon-search"></i>&nbsp;&nbsp;</a>
          </li>
        
      </ul>
    </div>
  </div>
</nav>

    <div class="view intro-2" id="background"
         style="background: url('https://up.enterdesk.com/edpic_source/ba/d3/3c/bad33cdd4268554aea3a176b118d8b14.jpg')no-repeat center center;
           background-size: cover;
           background-attachment: fixed;">
      <div class="full-bg-img">
        <div class="mask rgba-black-light flex-center">
          <div class="container text-center white-text fadeInUp">
            <span class="h2" id="subtitle">
              
            </span>

            
              <br>
              
                <p class="mt-3">
                  <i class="fas fa-calendar-alt" aria-hidden="true"></i>&nbsp;
                  星期二, 二月 11日 2020, 11:49 中午
                </p>
              

              <p>
                
                  
                  &nbsp;<i class="far fa-chart-bar"></i>
                  <span class="post-count">
                    1.2k 字
                  </span>&nbsp;
                

                
                  
                  &nbsp;<i class="far fa-clock"></i>
                  <span class="post-count">
                      4 分钟
                  </span>&nbsp;
                

                
                  <!-- 不蒜子统计文章PV -->
                  
                  &nbsp;<i class="far fa-eye" aria-hidden="true"></i>&nbsp;
                  <span id="busuanzi_container_page_pv">
                    <span id="busuanzi_value_page_pv"></span> 次
                  </span>&nbsp;
                
              </p>
            
          </div>

          
        </div>
      </div>
    </div>
  </header>

  <main>
    
      

<div class="container-fluid">
  <div class="row">
    <div class="d-none d-lg-block col-lg-2"></div>
    <div class="col-lg-8 nopadding-md">
      <div class="py-5 z-depth-3" id="board">
        <div class="post-content mx-auto" id="post">
          <div class="markdown-body">
            <p>我为什么把Hexo部署到Gitee(码云)上呢？什么是Pages服务呢？</p>
<p>首先，Gitee Pages 服务是一个支持Jekyll、Hugo、Hexo静态网站的服务，它是免费使用的， 但仅供博客 / 门户 / 开源项目网站 / 开源项目静态效果演示用途。就是说，我们把Hexo搭建的博客，放到Gitee上，它给我们指定一个URL地址，只要有网络，我们就可以通过URL地址来访问我们搭建的Hexo博客，我们就不用购买服务器了。</p>
<p>除了Gitee这样的平台外，还有Github、Gitlab和Coding，其中Coding和腾讯合作，国内访问速度不慢，Github我也是可以访问的，但是有的页面访问速度很慢，Gitlab我的网络压根就加载不出来，由于国内Gitee的访问速度还好，以及 之前也部署到Github和coding过，于是这次就部署到Gitee上。</p>
<h2 id="第一步：注册Gitee账号，新建项目仓库"><a href="#第一步：注册Gitee账号，新建项目仓库" class="headerlink" title="第一步：注册Gitee账号，新建项目仓库"></a>第一步：注册Gitee账号，新建项目仓库</h2><ul>
<li>gitee官网： <a href="https://gitee.com/" target="_blank" rel="noopener">https://gitee.com/</a></li>
</ul>
<h3 id="1-注册账户（直达注册页面），能记住密码就行，不过我总是忘记密码🙃"><a href="#1-注册账户（直达注册页面），能记住密码就行，不过我总是忘记密码🙃" class="headerlink" title="1.注册账户（直达注册页面），能记住密码就行，不过我总是忘记密码🙃"></a>1.注册账户（直达注册页面），能记住密码就行，不过我总是忘记密码🙃</h3><p><img src="https://s2.ax1x.com/2020/02/09/1hTgoR.png" srcset="/img/loading.gif" alt="请输入图片描述"></p>
<h3 id="2-新建项目仓库"><a href="#2-新建项目仓库" class="headerlink" title="2.新建项目仓库:"></a>2.新建项目仓库:</h3><p>忘说了，如果网页为英文，不太友好，在网站最底部右下角可以切换为中文。</p>
<p><img src="https://s2.ax1x.com/2020/02/09/1hTXfP.png" srcset="/img/loading.gif" alt="请输入图片描述"><br><img src="https://s2.ax1x.com/2020/02/09/1hTvSf.png" srcset="/img/loading.gif" alt="请输入图片描述"></p>
<p>关于这个仓库名，还是要记录一些重要事情的：如果你填写的仓库名和自己的用户名不一致，Gitee Pages的访问地址就会是  <code>https://你的用户名.gitee.io/仓库名</code>，如果你填写的仓库名是你的用户名，那么Pages的访问地址就是  <code>https://你的用户名.gitee.io</code>，这就是两者的区别。</p>
<h2 id="第二步：配置Git"><a href="#第二步：配置Git" class="headerlink" title="第二步：配置Git"></a>第二步：配置Git</h2><h3 id="1-配置本地的git"><a href="#1-配置本地的git" class="headerlink" title="1. 配置本地的git"></a>1. 配置本地的git</h3><p>git提供一个 git config 的工具，我们需要用它来配置本地的git：使用命令 <code>git config --global user.name &quot;你的Gitee的用户名&quot;</code> 和 <code>git config --global user.email &quot;你的注册邮箱地址&quot;来配置个人用户信息</code>。</p>
<p><img src="https://s2.ax1x.com/2020/02/09/1hXmX6.png" srcset="/img/loading.gif" alt="请输入图片描述"></p>
<p>这两条配置很重要，每次 Git 提交时都会引用这两条信息，说明是谁提交了更新，所以会随更新内容一起被永久纳入历史记录： 加上<code>--global</code> 就起全局作用， 更改的配置文件就是位于你用户主目录下的那个(<code>~/.gitconfig</code>)，那么以后你所有的仓库都会默认使用这里配置的用户信息。如果要在某个特定的仓库中使用其他名字或者电邮，只要去掉 <code>–global</code> 选项重新配置即可，新的设定保存在当前仓库的 <code>.git/config</code> 文件里。</p>
<h3 id="2-检查已有的配置信息"><a href="#2-检查已有的配置信息" class="headerlink" title="2.检查已有的配置信息"></a>2.检查已有的配置信息</h3><p>要检查已有的配置信息，可以使用 git config –list 命令：</p>
<pre><code>$ git config --list
user.name=你配置的用户名
user.email=你配置的邮箱地址</code></pre><h2 id="第三步：配置Hexo"><a href="#第三步：配置Hexo" class="headerlink" title="第三步：配置Hexo"></a>第三步：配置Hexo</h2><h3 id="1-修改-config-yml的url和root"><a href="#1-修改-config-yml的url和root" class="headerlink" title="1.修改__config.yml的url和root"></a>1.修改__config.yml的url和root</h3><p>为了能让Hexo生成的静态界面可以在Gitee Pages上生效， 需要给Hexo 配置文件_config.yml的url和root做如下修改：</p>
<pre><code>url: https://你的用户名.gitee.io/你的仓库名   #例如url: https://xxx.gitee.io/blog
root: /你的仓库名           #例如/blog</code></pre><h3 id="2-安装hexo-deployer-git插件"><a href="#2-安装hexo-deployer-git插件" class="headerlink" title="2.安装hexo-deployer-git插件"></a>2.安装hexo-deployer-git插件</h3><p>为了Hexo能利用Git将静态网站文件推送到远程Gitee仓库中，需要下载Hexo插件：hexo-deployer-git</p>
<pre><code>#安装hexo-deployer-git，要在博客网站的根目录下安装
$ cnpm install hexo-deployer-git --save</code></pre><p>之后，需要修改 Hexo 配置文件_config.yml 的deploy：</p>
<pre><code>deploy:
  type: git
  repo: &lt;repository url&gt;     #例如 https://gitee.com/xxxx/blog.git
  branch: [branch]
  message: [message]</code></pre><table>
<thead>
<tr>
<th>选项</th>
<th>描述</th>
<th>默认值</th>
</tr>
</thead>
<tbody><tr>
<td>type</td>
<td>版本管理工具</td>
<td>没有默认值，必填，我们使用Git就填git</td>
</tr>
<tr>
<td>repo</td>
<td>目标仓库的URL链接</td>
<td>必填，例如<a href="https://gitee.com/xxx/blog.git" target="_blank" rel="noopener">https://gitee.com/xxx/blog.git</a></td>
</tr>
<tr>
<td>branch</td>
<td>仓库分支</td>
<td>一般写maser  gh-pages (GitHub) coding-pages (Coding.net)  master (others)</td>
</tr>
<tr>
<td>message</td>
<td>自定义提交信息</td>
<td>默认是提交是的时间，例如“Site updated: 2020-02-09 23:07:41”</td>
</tr>
</tbody></table>
<p>关于repo的填写，填的东西可以在仓库右边的克隆/下载处复制HTTPS链接<br><img src="https://s2.ax1x.com/2020/02/09/1hvcwT.png" srcset="/img/loading.gif" alt="请输入图片描述"></p>
<h2 id="第四步：生成界面，推送到Gitee"><a href="#第四步：生成界面，推送到Gitee" class="headerlink" title="第四步：生成界面，推送到Gitee"></a>第四步：生成界面，推送到Gitee</h2><pre><code>$ hexo g      #生成静态文件
$ hexo clean  #清除缓存
$ hexo d      #提交并推送到远端仓库</code></pre><p><code>hexo d</code>这一步需要输入用户名和密码：用户名是明文的，会显示，但密码是不会有任何显示的，就像空气一般透明，但是系统会录入你的密码，不要以为你没有输进去，尽管大胆的输入！</p>
<p><img src="https://s2.ax1x.com/2020/02/09/1hzwMn.png" srcset="/img/loading.gif" alt="请输入图片描述"></p>
<h2 id="第五步：开启仓库的Pages服务，访问网页"><a href="#第五步：开启仓库的Pages服务，访问网页" class="headerlink" title="第五步：开启仓库的Pages服务，访问网页"></a>第五步：开启仓库的Pages服务，访问网页</h2><p>在你的仓库中开启Pages服务：</p>
<p><img src="https://s2.ax1x.com/2020/02/09/1hzTIO.png" srcset="/img/loading.gif" alt="请输入图片描述"><br><img src="https://s2.ax1x.com/2020/02/09/1hzbJe.png" srcset="/img/loading.gif" alt="请输入图片描述"><br><img src="https://s2.ax1x.com/2020/02/09/1hzHiD.png" srcset="/img/loading.gif" alt="请输入图片描述"></p>
<p>最后，访问一下那个地址，看是否能够访问的了！</p>

            <hr>
          </div>
          <br>
          <div>
            <p>
            
              <span>
                <i class="iconfont icon-inbox"></i>
                
                  <a class="hover-with-bg" href="/categories/%E5%8D%9A%E5%AE%A2%E6%90%AD%E5%BB%BA">博客搭建</a>
                  &nbsp;
                
              </span>&nbsp;&nbsp;
            
            
              <span>
                <i class="iconfont icon-tag"></i>
                
                  <a class="hover-with-bg" href="/tags/%E5%8D%9A%E5%AE%A2%E6%90%AD%E5%BB%BA">博客搭建</a>
                
              </span>
            
            </p>
            
              <p class="note note-warning">本博客所有文章除特别声明外，均采用 <a href="https://zh.wikipedia.org/wiki/Wikipedia:CC_BY-SA_3.0%E5%8D%8F%E8%AE%AE%E6%96%87%E6%9C%AC" target="_blank" rel="nofollow noopener noopener">CC BY-SA 3.0协议</a> 。转载请注明出处！</p>
            
          </div>
        </div>
      </div>
    </div>
    <div class="d-none d-lg-block col-lg-2 toc-container">
      
  <div id="toc">
    <p class="h4"><i class="far fa-list-alt"></i>&nbsp;目录</p>
    <div id="tocbot"></div>
  </div>

    </div>
  </div>
</div>

<!-- custom -->


<!-- Comments -->
<div class="col-lg-7 mx-auto nopadding-md">
  <div class="container comments mx-auto" id="comments">
    
      <br><br>
      
      
  <div id="vcomments" style="width: 90%; margin: 0 auto;"></div>
  <script defer src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
  <script defer src="//unpkg.com/valine/dist/Valine.min.js"></script>

  <script>
    var notify = 'false' === true;
    var verify = 'false' === true;
    var oldLoad = window.onload;
    window.onload = function () {
      new Valine({
        el: '#vcomments',
        notify: notify,
        verify: verify,
        app_id: "DySPQjS0lPUGBNigiGPGXDbU-gzGzoHsz",
        app_key: "HNYP8577C8AqC85sSrQVzwQy",
        placeholder: "快快挥霍你的口水吧~",
        avatar: "retro",
        meta: ['nick', 'mail', 'link'],
        pageSize: "10",
      });
      oldLoad && oldLoad();
    };
  </script>
  <noscript>Please enable JavaScript to view the <a href="https://valine.js.org" target="_blank" rel="nofollow noopener noopener">comments
      powered by Valine.</a></noscript>


    
  </div>
</div>

    
  </main>

  
    <a class="z-depth-1" id="scroll-top-button" href="#" role="button">
      <i class="fa fa-chevron-up scroll-top-arrow" aria-hidden="true"></i>
    </a>
  

  
    <div class="modal fade" id="modalSearch" tabindex="-1" role="dialog" aria-labelledby="ModalLabel"
     aria-hidden="true">
  <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header text-center">
        <h4 class="modal-title w-100 font-weight-bold">搜索</h4>
        <button type="button" id="local-search-close" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body mx-3">
        <div class="md-form mb-5">
          <input type="text" id="local-search-input" class="form-control validate">
          <label data-error="x" data-success="v"
                 for="local-search-input">关键词</label>
        </div>
        <div class="list-group" id="local-search-result"></div>
      </div>
    </div>
  </div>
</div>
  

  <footer class="mt-5">
  <div class="text-center py-3">
    <a href="https://hexo.io" target="_blank" rel="nofollow noopener"><b>Hexo</b></a>
    <i class="iconfont icon-love"></i>
    <a href="https://github.com/fluid-dev/hexo-theme-fluid" target="_blank" rel="nofollow noopener"> <b>Fluid</b></a>
    <br>

    
  
    <!-- 不蒜子统计PV -->
    
    &nbsp;<span id="busuanzi_container_site_pv">总访问量 
          <span id="busuanzi_value_site_pv"></span> 次</span>&nbsp;
  
  
    <!-- 不蒜子统计UV -->
    
    &nbsp;<span id="busuanzi_container_site_uv">总访客数 
            <span id="busuanzi_value_site_uv"></span> 人</span>&nbsp;
  
  <br>



    


    <!-- cnzz Analytics icon -->
    

  </div>
</footer>

<!-- SCRIPTS -->
<script src="/lib/jquery/jquery.min.js" ></script>
<script src="/lib/popper/popper.min.js" ></script>
<script src="/lib/bootstrap/js/bootstrap.min.js" ></script>
<script src="/lib/mdbootstrap/js/mdb.min.js" ></script>
<script src="/js/main.js" ></script>


  <script src="/js/lazyload.js" ></script>



  
    <script src="/lib/tocbot/tocbot.min.js" ></script>
  
  <script src="/js/post.js" ></script>



  <script src="/lib/smooth-scroll/smooth-scroll.min.js" ></script>



  <script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js" ></script>


<!-- Plugins -->


  

  

  

  

  <!-- cnzz Analytics -->
  



  <script src="/lib/prettify/prettify.min.js" ></script>
  <script>
    $(document).ready(function () {
      $('pre').addClass('prettyprint  linenums');
      prettyPrint();
    })
  </script>



  <script src="/lib/typed/typed.min.js" ></script>
  <script>
    var typed = new Typed('#subtitle', {
      strings: [
        '  ',
        "Hexo博客部署到Gitee(码云)平台，开启Pages 服务&nbsp;",
      ],
      cursorChar: "_",
      typeSpeed: 70,
      loop: false,
    });
    typed.stop();
    $(document).ready(function () {
      $(".typed-cursor").addClass("h2");
      typed.start();
    });
  </script>



  <script src="/lib/anchor/anchor.min.js" ></script>
  <script>
    anchors.options = {
      placement: "right",
      visible: "false",
      
    };
    var el = "h1,h2,h3,h4,h5,h6".split(",");
    var res = [];
    for (item of el) {
      res.push(".markdown-body > " + item)
    }
    anchors.add(res.join(", "))
  </script>



  <script src="/js/local-search.js" ></script>
  <script>
    var path = "/local-search.xml";
    var inputArea = document.querySelector("#local-search-input");
    inputArea.onclick = function () {
      getSearchFile(path);
      this.onclick = null
    }
  </script>



  <script src="/lib/fancybox/jquery.fancybox.min.js" ></script>
  <script>
    $("#post img:not(.no-zoom img, img[no-zoom])").each(
      function () {
        var element = document.createElement("a");
        $(element).attr("data-fancybox", "images");
        $(element).attr("href", $(this).attr("src"));
        $(this).wrap(element);
      }
    );
  </script>





  
  
    <script>
      !function (e, t, a) {
        function r() {
          for (var e = 0; e < s.length; e++) s[e].alpha <= 0 ? (t.body.removeChild(s[e].el), s.splice(e, 1)) : (s[e].y--, s[e].scale += .004, s[e].alpha -= .013, s[e].el.style.cssText = "left:" + s[e].x + "px;top:" + s[e].y + "px;opacity:" + s[e].alpha + ";transform:scale(" + s[e].scale + "," + s[e].scale + ") rotate(45deg);background:" + s[e].color + ";z-index:99999");
          requestAnimationFrame(r)
        }

        function n() {
          var t = "function" == typeof e.onclick && e.onclick;
          e.onclick = function (e) {
            t && t(), o(e)
          }
        }

        function o(e) {
          var a = t.createElement("div");
          a.className = "heart", s.push({
            el: a,
            x: e.clientX - 5,
            y: e.clientY - 5,
            scale: 1,
            alpha: 1,
            color: c()
          }), t.body.appendChild(a)
        }

        function i(e) {
          var a = t.createElement("style");
          a.type = "text/css";
          try {
            a.appendChild(t.createTextNode(e))
          } catch (t) {
            a.styleSheet.cssText = e
          }
          t.getElementsByTagName("head")[0].appendChild(a)
        }

        function c() {
          return "rgb(" + ~~(255 * Math.random()) + "," + ~~(255 * Math.random()) + "," + ~~(255 * Math.random()) + ")"
        }

        var s = [];
        e.requestAnimationFrame = e.requestAnimationFrame || e.webkitRequestAnimationFrame || e.mozRequestAnimationFrame || e.oRequestAnimationFrame || e.msRequestAnimationFrame || function (e) {
          setTimeout(e, 1e3 / 60)
        }, i(".heart{width: 10px;height: 10px;position: fixed;background: #f00;transform: rotate(45deg);-webkit-transform: rotate(45deg);-moz-transform: rotate(45deg);}.heart:after,.heart:before{content: '';width: inherit;height: inherit;background: inherit;border-radius: 50%;-webkit-border-radius: 50%;-moz-border-radius: 50%;position: fixed;}.heart:after{top: -5px;}.heart:before{left: -5px;}"), n(), r()
      }(window, document);
    </script>
  







</body>
</html>
